//
//  UIControl+QuickDev.m
//  QuickDev
//
//  Created by 胡超 on 2018/1/29.
//  Copyright © 2018年 胡超., ltd. All rights reserved.
//

#import <objc/runtime.h>

#import "UIControl+Mango.h"

@implementation UIControl (Mango)

- (void)addBlockAction:(MMUIControlAction)action forControlEvents:(UIControlEvents)controlEvents {
    [self addTarget:self action:@selector(mm_BlockControlAction:) forControlEvents:controlEvents];
    objc_setAssociatedObject(self, "mm_controlAction", action, OBJC_ASSOCIATION_COPY_NONATOMIC);
}

- (void)mm_BlockControlAction:(id)sender {
    MMUIControlAction action = objc_getAssociatedObject(self, "mm_controlAction");
    if (action) {
        action(self);
    }
}

@end
